export default function (app) {

  app.directive('dateFormat', dateFormat);

  function dateFormat($filter) {
    'ngInject';
    let dateFilter = $filter('date');
    return {
      restrict: 'A',
      link: linkFn,
      require: 'ngModel'
    };

    function linkFn(scope, elm, attrs, ctrl) {
      function formatter(value) {
        return dateFilter(value, 'yyyy-MM-dd'); //format  
      }  

      function parser() {  
        return ctrl.$modelValue;  
      }  

      ctrl.$formatters.push(formatter);  
      ctrl.$parsers.unshift(parser);  
    }
  }
}